﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Rhino.Mocks;
using SwitBusiness;

namespace SwiTest
{
    //DummySwitch sınıfımızın doğru çalışıp çalışmadığnıı burada test ediyoruz.
    [TestClass]
    public class UTDummySwitch
    {
        [TestMethod]
        public void Compare_DummySwitchResult_Equal()
        {
            DummySwitch ds = new DummySwitch();
            ds.MinRate = 1;
            ds.MaxRate = 2;
            ds.CheckStatus();
            string expectedResult = @"Port	Name		Status		Vlan	Duplex	Speed	Type
Fa0/1	Port1		notconnect	trunk	a-full	a-100	10/100BaseT
Fa0/2	Port2		connected	1	auto	auto	10/100BaseT
Fa0/3	Port3		connected	1	auto	auto	10/100BaseT
Fa0/4	Port4		connected	1	auto	auto	10/100BaseT
Fa0/5	Port5		connected	1	auto	auto	10/100BaseT
Fa0/6	Port6		notconnect	trunk	a-full	a-100	10/100BaseT
Fa0/7	Port7		connected	1	auto	auto	10/100BaseT
Fa0/8	Port8		connected	1	auto	auto	10/100BaseT
Fa0/9	Port9		connected	1	auto	auto	10/100BaseT
Fa0/10	Port10		connected	1	auto	auto	10/100BaseT
Fa0/11	Port11		connected	1	auto	auto	10/100BaseT
Fa0/12	Port12		connected	1	auto	auto	10/100BaseT
Fa0/13	Port13		connected	1	auto	auto	10/100BaseT
Fa0/14	Port14		connected	1	auto	auto	10/100BaseT
Fa0/15	Port15		connected	1	auto	auto	10/100BaseT
Fa0/16	Port16		connected	1	auto	auto	10/100BaseT
seTX
S2960_ISD_1#";
            Assert.AreEqual(expectedResult,ds.Status);            
        }


        [TestMethod] //Ignore
        public void CompareNotConnectedLines_DummySwitchResult_Equal()
        {
            
            DummySwitch ds = new DummySwitch();
            ds.ConnectServer();
            ds.CheckStatus();
            var expectedResult = ds.Status.Replace("\r", "").Split(Environment.NewLine.ToCharArray());



            foreach (var line in ds.DISCONNECTED_PORT_INDEXES)
            {

                Assert.AreEqual(false, getStatusFromLine(expectedResult[line+1]));
            }

        }

        private bool getStatusFromLine(string status) {
            var expectedStatus = status.Split('\t');

            return expectedStatus[3] == "connected";
            
        }
    }
}
